package core;

import java.util.List;

public class GoldSimulator {

	public static void main(String[] args) {
		GoldDataRead read = new GoldDataRead("data/XAUUSD.txt", 00000, 100000);

		PersonAccount account = new PersonAccount(100000);

		BaseDecision decision = new GridDecision(account);

		List<PriceData> prices = read.getAllDatas();
		List<PriceData> movingAvePrices = CalculateTools.calMovingAverage(prices, 1 * 22 * 60);

		if (null == movingAvePrices) {
			System.err.println("moving average interval is not suitable! EXIT!");
			System.exit(-1);
		}

		PriceData aPrice = null;
		PriceData aMovingAvePrice = null;
		for (int i = 0; i < prices.size(); ++i) {
			aPrice = prices.get(i);
			aMovingAvePrice = movingAvePrices.get(i);

			decision.Update(aPrice.open * (1 + TradeConstants.TRADEFEE), aPrice.open,
							aMovingAvePrice.open, aPrice.time);
		}

		System.out.println("Result : " + account.toAllResults());

	}
}
